﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Database.Classes;

namespace smallDeimos.Game.GameTools
{
    public partial class BattleCalc : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            int DefDs = int.Parse(DsDef.Text);
            int DefCr = int.Parse(CrDef.Text);
            int DefBs = int.Parse(BsDef.Text);
            int DefPhys = int.Parse(DefPhy.Text);
            int DefMathe = int.Parse(DefMath.Text);
            int DefAtta = int.Parse(DefAtt.Text);
            int DefDefe = int.Parse(DefDef.Text);
            double DefStarBase = double.Parse(Sb.Text);

            int AttDs = int.Parse(DsAtt.Text);
            int AttCr = int.Parse(CrAtt.Text);
            int AttBs = int.Parse(BsAtt.Text);
            int AttPhys = int.Parse(AttPhy.Text);
            int AttMathe = int.Parse(AttMath.Text);
            int AttAtta = int.Parse(AttAtt.Text);
            int AttDefe = int.Parse(AttDef.Text);

            int expDef = 0, expAtt = 0;
            int d1 = AttDs, d2 = DefDs, c1 = AttCr, c2 = DefCr, b1 = AttBs, b2 = DefBs;
            double s2 = DefStarBase;
            double chanceForWinForAttacker, winnerLoses;
            bool winer = Equations.AttackProcedure(AttAtta, AttDefe, AttPhys, AttMathe, ref d1, ref c1, ref b1, DefAtta, DefDefe, DefPhys, DefMathe, ref d2, ref c2, ref b2, ref s2, out expAtt, out expDef, out chanceForWinForAttacker, out winnerLoses);

            DsDefLeft.Text = d2.ToString();
            CrDefLeft.Text = c2.ToString();
            BsDefLeft.Text = b2.ToString();
            SbLeft.Text = s2.ToString();

            DsAttLeft.Text = d1.ToString();
            CrAttLeft.Text = c1.ToString();
            BsAttLeft.Text = b1.ToString();
            DefExp.Text = expDef.ToString();
            AttExp.Text = expAtt.ToString();
            ChanceAtt.Text = ((int)(chanceForWinForAttacker * 100)).ToString() + "%";
            ChanceDef.Text = ((int)((1 - chanceForWinForAttacker) * 100)).ToString() + "%";
        }
    }
}
